from django.contrib import admin
from .models import BaseSensitiveInfo
from import_export import resources
from import_export.admin import ImportExportModelAdmin


# Register your models here.

admin.site.site_header = '敏感数据管理后台'
admin.site.site_title = '敏感数据管理后台'
admin.site.index_title = '敏感数据管理后台'

@admin.register(BaseSensitiveInfo)
class BaseSensitiveInfoadmin(ImportExportModelAdmin):
    list_display = ("录入时间","数据库","数据表","列名","列名称","备注","是否收录蓝鲸","数据分类","数据分级","维护人")
    list_filter = ("数据库","数据表","列名","列名称","备注","是否收录蓝鲸","数据分类","数据分级","维护人")
    search_fields = ("数据库","数据表","列名","列名称","备注","是否收录蓝鲸","数据分类","数据分级")
    raw_id_fields = ("维护人",)
    date_hierarchy = "录入时间"
    ordering = ['数据库','数据表']

# admin.site.register(BaseSensitiveInfo,BaseSensitiveInfoadmin)


class BaseSensitiveInfoResource(resources.ModelResource):
    class Meta:
        model = BaseSensitiveInfo
        fields = [
            "录入时间",
            "数据库",
            "数据表",
            "列名",
            "列名称",
            "备注",
            "是否收录蓝鲸",
            "数据分类",
            "数据分级",
            "维护人",
        ]

        export_order = ('数据库','数据表')

basesensitiveinfo_resource = BaseSensitiveInfoResource()
dataset = basesensitiveinfo_resource.export()
dataset.csv
